Simple script to iterate links hanging

Hi All,

We have some issues iterating over links of a module with the seemingly trivial script below.

The script does work fine for most modules we tried, but Doors will hang up when the script is executed on two particular modules of a customer.

Any idea what is wrong here?

Module m = current

pragma encoding, "UTF-8"

Object o, targetobj 
ModName_ targetmod
Link lnk 


for o in m do {
   for lnk in o -> "*" do { 
     print sourceAbsNo(lnk) "->"
     targetmod = target lnk
     print qualifiedUniqueID(m) "/"
     print targetAbsNo(lnk)
   } 
}

 


Benjamin Engele - Tue Sep 25 03:29:14 EDT 2018

Re: Simple script to iterate links hanging
IBM_Gust - Tue Sep 25 08:16:54 EDT 2018

Try changing code to:

 Module m = current
pragma encoding, "UTF-8"
Object o, targetobj
ModName_ targetmod
Link lnk
Buffer b =create
for o in m do {
   for lnk in o -> "*" do {
     b+= sourceAbsNo(lnk) "->"
     targetmod = target lnk
     b+=  qualifiedUniqueID(m) "/"
     b+=  targetAbsNo(lnk) "\n"
   }
}
print b ""

Re: Simple script to iterate links hanging
Benjamin Engele - Tue Sep 25 09:21:40 EDT 2018

Thanks for the suggestion, will ask colleague with access to the customer data to give it a try.

Can it really make a difference to put the data into a buffer before printing it?

Re: Simple script to iterate links hanging
davidcs - Tue Sep 25 15:28:25 EDT 2018

Benjamin Engele - Tue Sep 25 09:21:40 EDT 2018

Thanks for the suggestion, will ask colleague with access to the customer data to give it a try.

Can it really make a difference to put the data into a buffer before printing it?

Your script is fine.

 

First, tell the person running the script the "stops responding" message in DOORS is normal when executing DXLs and should let it continue to execute. 

 

Also, write the output to a file so you can monitor the file in Notepad++. DOORS isn't hanging, it is probably just taking a long time to iterate over the links. 

Module m = current
Stream lStream = write("D:\\Links.txt")
pragma encoding, "UTF-8"

Object o, targetobj 
Link lnk 

for o in m do {
   for lnk in o -> "*" do {
     lStream << sourceAbsNo(lnk) "->"  qualifiedUniqueID(m) "/" targetAbsNo(lnk) "\n"
     flush(lStream)
   } 
}
close(lStream)

Re: Simple script to iterate links hanging
Benjamin Engele - Wed Sep 26 07:19:13 EDT 2018

You are right about iterating taking a long time...

The colleague just reported the script actually finished after significant time.

 

I am also able to reproduce the problem with a test module with several thousand links.

 

The tip with writing to a file is great, it will help a lot to see what is actually happening instead of just waiting and praying.

Re: Simple script to iterate links hanging
davidcs - Wed Sep 26 07:27:41 EDT 2018

Benjamin Engele - Wed Sep 26 07:19:13 EDT 2018

You are right about iterating taking a long time...

The colleague just reported the script actually finished after significant time.

 

I am also able to reproduce the problem with a test module with several thousand links.

 

The tip with writing to a file is great, it will help a lot to see what is actually happening instead of just waiting and praying.

Also, in your original script most to the time is being consumed via the 'print' function. When you write the data to a file the script will run much faster.

Re: Simple script to iterate links hanging
Benjamin Engele - Wed Sep 26 07:36:50 EDT 2018

Actually writing to the file seems to be the solution here - debugging anything performance related with print is a bad idea.

Seems the print command is slow and the more lines there are in the console the slower it will get.

Executing your script did complete in no time.

When printing the link and writing it to a fail the script processed ~4000 links in first 30 seconds and less than 2000 next 30 seconds, getting slower as more content is printed.

 

 

Re: Simple script to iterate links hanging
anotherDaniel - Wed Oct 17 19:26:55 EDT 2018

I have started adding progress bars to scripts that take a while. If it is relatively easy to get a precount (e.g., all objects in the view) then it helps pass the time and reassure my users (and me) that it is still working.

 

Daniel